﻿using System;
using System.Activities;
using System.Linq.Expressions;

namespace WFT.Activities
{
    /// <summary>
    /// Execute an expression with the activity context in parameter
    /// </summary>
    public class ExpressionActivity : CodeActivity
    {
        public ExpressionActivity()
        {

        }

        public ExpressionActivity(Expression<Action<ActivityContext>> expression)
        {
            Expression = expression;
        }

        public Expression<Action<ActivityContext>> Expression { get; set; }

        protected override void Execute(CodeActivityContext context)
        {
            Expression.Compile()(context);
        }
    }
}
